<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<script type="text/javascript" src="__APP__/statics/jquery.1.4.2.js"></script>

<div style="font-family:'微软雅黑'">
    <ul>
	卡号：
	<input type="text" id="wallet" size="5" value="LP0001">
	</ul>
	<ul>
	卡密：
	 <input type="text" id="code1" size="3" maxlength=4>-
	 <input type="text" id="code2" size="3" maxlength=4>-
	 <input type="text" id="code3" size="3" maxlength=4>-
	 <input type="text" id="code4" size="3" maxlength=4>
	 <input type="button" id="ckcou" value="验证" style="border:0px;color:#fff;padding:3px;font-weight:bold;background:#ff5500" onclick="check()">
	 <span id="result"></span>
 </div>


<script>
    $("#code1").bind("keyup",function(){
	   if($(this).val().length==4){$("#code2").focus();}
	})
	$("#code2").bind("keyup",function(){
	   if($(this).val().length==4){$("#code3").focus();}
	})
	$("#code3").bind("keyup",function(){
	   if($(this).val().length==4){$("#code4").focus();}
	})

	function check(){
		var wallet=$("#wallet").val();
		var code=$("#code1").val()+$("#code2").val()+$("#code3").val()+$("#code4").val();
		$.ajax({
		    type:"POST",
			url:"__URL__/wallet/?action=check",
			dataType:"json",
			data:{'wallet_id':wallet,'code':code},
			success:function(data){
			     if(data.result==1){
				    jSuccess("<strong>验证通过！请点击充值完成操作</strong>",{TimeShown : 2000,VerticalPosition : 'center',HorizontalPosition : 'center'})
				    $("#wallet").attr('disabled','true');
					$("#code1").attr('disabled','true');
					$("#code2").attr('disabled','true');
					$("#code3").attr('disabled','true');
					$("#code4").attr('disabled','true');
					$("#ckcou").attr('disabled','true');
                    $("<input style='border:0px;color:#fff;padding:3px;font-weight:bold;background:#ff5500' type='button' value='立即充值' onclick='charge()'>").appendTo($("#result"));
				}else{
				    jError("<strong>验证失败！请核对卡号、卡密是否正确</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
				}
			}
		})
	}

	function charge(){
		var wallet=$("#wallet").val();
		var code=$("#code1").val()+$("#code2").val()+$("#code3").val()+$("#code4").val();
		$.ajax({
		    type:"POST",
			url:"__URL__/wallet/?action=charge",
			dataType:"json",
			data:{'wallet_id':wallet,'code':code},
			success:function(data){
			  jSuccess("<strong>恭喜你，充值成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){window.parent.location.reload();}})
			}
		})
	}

</script>

<link rel="stylesheet" type="text/css" href="__APP__/statics/css/jNotify.jquery.css" />
<script type="text/javascript" src="__APP__/statics/jNotify.jquery.js"></script>